import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;


public class ControlFrame extends JFrame implements ActionListener{
	
	

	JButton Up;
	JButton Down;
	JButton Left;
	JButton Right;
	JButton Back;
	JButton Forth;
	
	Main delegate;
	
	public ControlFrame(Main $delegate){
		
		delegate = $delegate;
		Setup();
		
	}

	public void Setup(){
		
		setBounds(100, 100,308, 270);
		
		setLocation(delegate.getWidth()+delegate.getLocationOnScreen().x, delegate.getLocationOnScreen().y+delegate.getHeight()-this.getHeight());
		
		Up = new JButton("Up");
		Up.setBounds(150+50, 25+25, 50, 50);
		getContentPane().add(Up);
		Up.addActionListener(this);
		
		Down = new JButton("Dn");
		Down.addActionListener(this);
		Down.setBounds(150+50, 75+25, 50, 50);
		getContentPane().add(Down);
		
		Left = new JButton("<");
		Left.addActionListener(this);
		Left.setBounds(0+50, 50+25, 50, 50);
		getContentPane().add(Left);
		
		Right = new JButton(">");
		Right.addActionListener(this);
		Right.setBounds(100+50, 50+25, 50, 50);
		getContentPane().add(Right);
		
		Forth = new JButton("^");
		Forth.addActionListener(this);
		Forth.setBounds(50+50, 0+25, 50, 50);
		getContentPane().add(Forth);
		
		Back =  new JButton("v");
		Back.addActionListener(this);
		Back.setBounds(50+50, 100+25, 50, 50);
		getContentPane().add(Back);
		
		
		JButton Filler = new JButton();
		Filler.setBounds(50+50,50+25,50,50);
		getContentPane().add(Filler);
		Filler.setVisible(false);
		//pack();
		this.setVisible(true);
		
	}
	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		if(e.getSource() == Up){
			
			delegate.control(CommandParameters.UP);
			
		}else if(e.getSource() == Down){
			
			delegate.control(CommandParameters.DOWN);
			
		}else if(e.getSource() == Left){
			
			delegate.control(CommandParameters.LEFT);
			
		}else if(e.getSource() == Right){
			
			delegate.control(CommandParameters.RIGHT);
			
		}else if(e.getSource() == Back){
			
			delegate.control(CommandParameters.BACK);
			
		}else if(e.getSource() == Forth){
			
			delegate.control(CommandParameters.FORTH);
			
		}
	}
	
	
	
	
	
	
}
